package com.donggua.aichebao.commonui.home;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.donggua.aichebao.commonui.R;

import org.w3c.dom.Text;

/**
 * Created by Administrator on 2017-08-08.
 */
//com.donggua.aichebao.commonui.home.HomeSwitchLayout
public class HomeSwitchLayout extends LinearLayout{
    private TextView tvBusy;
    private TextView tvEmpty;
    public HomeSwitchLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.setOrientation(LinearLayout.HORIZONTAL);
        this.setGravity(Gravity.CENTER_VERTICAL);
        tvEmpty = getTextView(context);
        tvBusy = getTextView(context);
        tvEmpty.setLayoutParams(getMyLayoutParams());
        tvBusy.setLayoutParams(getMyLayoutParams());
        this.addView(tvEmpty);
        this.addView(tvBusy);
        String empty = context.getResources().getString(R.string.dgHomeEmpty);
        String busy = context.getResources().getString(R.string.dgHomeBusy);
        tvEmpty.setText(empty);
        tvBusy.setText(busy);

    }

    private LinearLayout.LayoutParams getMyLayoutParams(){
        LinearLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                          ViewGroup.LayoutParams.MATCH_PARENT);
        layoutParams.weight = 1;
        layoutParams.width = 0;
        return layoutParams;
    }

    private TextView getTextView(Context context){
        TextView textView = new TextView(context);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,25);
        textView.setTextColor(0xffffffff);
        textView.setBackgroundColor(0xff00ffff);
        textView.setGravity(Gravity.CENTER);
        return textView;
    }
}
